package ccxz.biz;

import ccxz.biz.view.HomeView;
import de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.stage.Stage;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@SpringBootApplication
public class SetupApplication extends AbstractJavaFxApplicationSupport {
    /**
     * 存放控制器
     */
    public static Map<String, Object> controllers = new HashMap<String, Object>();

    /**
     * root用户标志
     */
    public static boolean ROOT = false;

    public static void main(String[] args) {
        launch(SetupApplication.class, HomeView.class, args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setOnCloseRequest(event -> {
            Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
            alert.setTitle("退出确认框");
            //设置对话框的 icon 图标
            alert.initOwner(stage);
            alert.setHeaderText("您确定要现在退出程序？");
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get() == ButtonType.CANCEL) {
                event.consume();
            }

        });
        super.start(stage);
    }

}